package com.nwpusp.display.views.components;

import com.example.petssports.R;
import com.nwpusp.display.GlobalVar;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.Log;
import android.view.View;

public class ServerListBar extends View{
	public Bitmap barBitmap;
	public float x;
	public float y;
	public float scale;
	public float width;
	public float height;
	public String barStr;
	public int index;
	
	public ServerListBar(Context view,float scale,String str,int index){
		super(view);
		this.scale = scale;
		this.barStr = str;
		this.index = index;
		getBitmapSource();
		barBitmap = GlobalVar.VerticalScale(barBitmap,scale);
		width = barBitmap.getWidth();
		height = barBitmap.getHeight();
		barBitmap = GlobalVar.DrawSubList(width,height,barBitmap,barStr,24);
	}
	
	public void setLocation(float x ,float y){
		this.x = x;
		this.y = y;
	}
	
	private void getBitmapSource(){
		barBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.serverlistbar);
	}
	
	public boolean isClick(float xl,float yl){
		Log.d("aob_ipmsg","click");
		if((xl>x) && (xl<x+width)&&(yl>y-height/2)&&(yl<y+height+height/2)){
			GlobalVar.whichServer = index;
			return true;
		}
		else
			return false;
	}
	
	public Bitmap draw(){
		return barBitmap;
	}

}
